package day_2022_12_to_3.day;

/**
 * @author haomin
 * @date 2022/12/06 18:44
 **/
public class Day12_6_Review {
    class Solution {
        public int findRepeatNumber(int[] nums) {
            int i = 0;
            while(i < nums.length) {
                int m = nums[i];
                int n = nums[m];
                if(m == i) i++;
                else if(m == n) return m;
                else {
                    nums[m] = m;
                    nums[i] = n;
                }
            }
            return -1;
        }
    }
}